// $(document).scroll(() => {
//     if ($(this).scrollTop() > 400 && $(this).scrollTop() < $('.full-direcruit').offset().top * 1 + 300 - $('.full-direcruit').height()) {
//         $('.company-chat .text').addClass('animation fadeInDown')
//         $('.company-chat .figure').addClass('animation fadeIn')
//         $('.company-chat .figure-phone').addClass('animation fadeInUp')
//         $('.company-chat .figure-logo').addClass('animation bounceIn')

//         setTimeout(() => {
//             $('.company-chat .user-1').addClass('animation fadeIn show-boss-img')
//         }, 800)
//         setTimeout(() => {
//             $('.company-chat .user-2').addClass('animation fadeIn show-boss-img')
//         }, 1600)
//         setTimeout(() => {
//             $('.company-chat .user-3').addClass('animation fadeIn show-boss-img')
//         }, 2400)
//         setTimeout(() => {
//             $('.company-chat .user-4').addClass('animation fadeIn show-boss-img')
//         }, 3200)

//     } else if ($(this).scrollTop() > $('.full-direcruit').offset().top * 1 + 300 - $('.full-direcruit').height() && $(this).scrollTop() < $('.full-company') + 300 - $('.full-company').height()) {
//         console.log(321);
//         $('.full-direcruit .figure').addClass('animation fadeInLeft')
//         $('.full-direcruit .text').addClass('animation fadeInRight')
//     } else if ($(this).scrollTop() > $('.full-company') + 300 - $('.full-company').height() && $(this).scrollTop() < $('.full-decent') + 300 - $('.full-decent').height()) {
//         console.log(555);
//         $('.full-company .text').addClass('animation fadeInDown')
//         $('.full-company .figure-computer').addClass('animation fadeInUp')
//         $('.full-company .figure-logos li').addClass('animation fadeIn')

//     }
// })


//获取若有要观察的元素
const secs = document.querySelectorAll('.sec')


//创建IntersectionObserver API,entries为观察对象发生变化集合
var observer = new IntersectionObserver((entries, observerConfig) => {

    const target = entries[0].target

    if (target.className == 'sec company-chat') {
        $('.company-chat .text').addClass('animation fadeInDown')
        $('.company-chat .figure').addClass('animation fadeIn')
        $('.company-chat .figure-phone').addClass('animation fadeInUp')
        $('.company-chat .figure-logo').addClass('animation bounceIn')

        setTimeout(() => {
            $('.company-chat .user-1').addClass('animation fadeIn show-boss-img')
        }, 800)
        setTimeout(() => {
            $('.company-chat .user-2').addClass('animation fadeIn show-boss-img')
        }, 1600)
        setTimeout(() => {
            $('.company-chat .user-3').addClass('animation fadeIn show-boss-img')
        }, 2400)
        setTimeout(() => {
            $('.company-chat .user-4').addClass('animation fadeIn show-boss-img')
        }, 3200)

    } else if (target.className == 'sec full-direcruit') {
        $('.full-direcruit .figure').addClass('animation fadeInLeft')
        $('.full-direcruit .text').addClass('animation fadeInRight')
    } else if (target.className == 'sec full-company') {
        $('.full-company .text').addClass('animation fadeInDown')
        $('.full-company .figure-computer').addClass('animation fadeInUp')
        $('.full-company .figure-logos li').addClass('animation fadeIn')

    } else if (target.className == 'sec full-decent') {
        $.each($('.figure-cards>li'), function(index, item) {
            item.className = `card-${ index + 1 }`
        });

    }




}, {
    threshold: [0.3]
});


//监听所有需要观察的元素
secs.forEach(sec => {
    observer.observe(sec)
})

xdistans = 0

setInterval(function() {
    xdistans -= 1073.97
    xdistans = xdistans < -2147.98 ? 0 : xdistans
    $('.company-list').css({
        transform: `translate3d(${xdistans}px , 0px, 0px)`,
        transitionDuration: '0.5s'
    })
}, 6000)